package com.miplus.ccrm.core.service.crd;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.miplus.ccrm.common.JPubUtils;
import com.miplus.ccrm.core.controller.vo.credit.LoanRepayReqVo;
import com.miplus.ccrm.core.pojo.FiCreditcases;
import com.miplus.ccrm.core.pojo.IouLoanInvoiceInfo;
import com.miplus.ccrm.core.pojo.IouRepayPlan;
import com.miplus.ccrm.core.service.crd.IouRepayPlanService;
import com.miplus.ccrm.core.mapper.IouRepayPlanMapper;
import org.springframework.stereotype.Service;

/**
* @author wangzl
* @description 针对表【iou_repay_plan(还款计划文件(业务表))】的数据库操作Service实现
* @createDate 2024-11-07 13:41:44
*/
@Service
public class IouRepayPlanServiceImpl extends MPJBaseServiceImpl<IouRepayPlanMapper, IouRepayPlan>
    implements IouRepayPlanService{
    @Override
    public IPage<IouRepayPlan> getRepayPlanList(LoanRepayReqVo paras)
    {
        return selectJoinListPage(new Page<>(paras.getPageNum(),paras.getPageSize()),
                IouRepayPlan.class,
                new MPJLambdaWrapper<IouRepayPlan>()
                        .leftJoin(IouLoanInvoiceInfo.class,"ili",IouLoanInvoiceInfo::getLoanInvoiceId,IouRepayPlan::getLoanInvoiceId)
                       // .leftJoin(FiCreditcases.class,"fc",FiCreditcases::getCreditcaseid,IouLoanInvoiceInfo::getCreditcaseid)
                        .eq(JPubUtils.IsNotEmpty(paras.getLoanInvoiceId()),IouRepayPlan::getLoanInvoiceId,paras.getLoanInvoiceId())
                        .eq(JPubUtils.IsNotEmpty(paras.getCreditcaseid()),IouLoanInvoiceInfo::getCreditcaseid,paras.getCreditcaseid())
                        .selectAll(IouRepayPlan.class)
                        .selectAs("fun_getnames ('REPAYPLAN.STATUS', t.repay_plan_status)",IouRepayPlan::getRepayPlanStatusDesc)
                        .orderByDesc(IouRepayPlan::getLoanInvoiceId,IouRepayPlan::getCurrentNum)
                );
    }
}




